package com.midian.model.user;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.midian.model.common.BaseModel;
import com.midian.model.pic.Pic;
import com.midian.service.user.IUserService;

/**
 * 用户（工人/企业）
 * 
 * @author Mengfh
 * 
 */
@Entity
@Table(name = "user")
public class User extends BaseModel {
	private static final long serialVersionUID = 1L;
	/** 第三方唯一标识 */
	private String thirdId;
	/** 姓名 */
	private String name;
	/** 账号 */
	private String account;
	/** 密码 */
	@Column(updatable = false)
	private String password;
	/** 电话 */
	private String phone;
	
	private String headPicId;
	/** 头像 */
//	@ManyToOne(optional = true, fetch = FetchType.LAZY)
//	@JoinColumn(name = "headPicId",insertable=false,updatable=false)
//	private Pic headPic;
	/** 1：正常注册 2:微信 3:qq */
	private Integer userfrom = 1;
	/** 生日 */
	private Date birthday;
	/** 性别 0:女1：男 */
	private Integer sex;
	/** 身份1:普通会员2：企业 */
	private Integer identity;
	/** token */
	private String token;
	/** token生成时间 */
	private Date tokenTime;
	/** 是否为管理员 1：是2：否 */
	private Integer isAdmin = 2;
	

	public String getThirdId() {
		return thirdId;
	}

	public void setThirdId(String thirdId) {
		this.thirdId = thirdId;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getAccount() {
		return account;
	}

	public void setAccount(String account) {
		this.account = account;
	}

	public String getPassword() {
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

//	public Pic getHeadPic() {
//		return headPic;
//	}
//
//	public void setHeadPic(Pic headPic) {
//		this.headPic = headPic;
//	}

	public Integer getUserfrom() {
		return userfrom;
	}

	public void setUserfrom(Integer userfrom) {
		this.userfrom = userfrom;
	}

	public Date getBirthday() {
		return birthday;
	}

	public void setBirthday(Date birthday) {
		this.birthday = birthday;
	}

	public Integer getSex() {
		return sex;
	}

	public void setSex(Integer sex) {
		this.sex = sex;
	}

	/**
	 * 性别描述
	 * 
	 * @return
	 */
	@Transient
	public String getSexDesc() {
		String sexDesc = "";
		if (IUserService.SEX_MALE.equals(this.sex)) {
			sexDesc = "男";
		} else if (IUserService.SEX_FEMALE.equals(this.sex)) {
			sexDesc = "女";
		}
		return sexDesc;
	}

	public Integer getIdentity() {
		return identity;
	}

	public void setIdentity(Integer identity) {
		this.identity = identity;
	}

	public String getToken() {
		return token;
	}

	public void setToken(String token) {
		this.token = token;
	}

	public Date getTokenTime() {
		return tokenTime;
	}

	public void setTokenTime(Date tokenTime) {
		this.tokenTime = tokenTime;
	}

	public Integer getIsAdmin() {
		return isAdmin;
	}

	public void setIsAdmin(Integer isAdmin) {
		this.isAdmin = isAdmin;
	}

	public String getHeadPicId() {
		return headPicId;
	}

	public void setHeadPicId(String headPicId) {
		this.headPicId = headPicId;
	}
	
	
}
